package linc.spring.demo.editor;

import linc.spring.demo.bean.Role;

import java.beans.PropertyEditor;
import java.beans.PropertyEditorSupport;
import java.util.Random;

/**
 * @author yqlin
 * @date 2021/9/7 01:02
 * @description JDK中提供的类型转化工具类
 */
public class StringToRolePropertyEditor extends PropertyEditorSupport implements PropertyEditor {
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        Role role = new Role();
        role.setId(new Random().nextLong());
        role.setName(text);
        this.setValue(role);
    }
}
